#!/bin/bash

SCRIPT_DIR=`dirname $BASH_SOURCE`

WILDFLY_BIN=$SCRIPT_DIR/../target/wildfly-8.0.0.Final/bin/./standalone.sh
WILDFLY_CLI=$SCRIPT_DIR/../target/wildfly-8.0.0.Final/bin/./jboss-cli.sh

SERVICE_DIR=$SCRIPT_DIR/../config/services/
PLUGIN_DIR=$SCRIPT_DIR/../../knot-general-plugins/target/


echo "starting wildfly"
chmod +x $WILDFLY_BIN
$WILDFLY_BIN -Dknot.services.dir=$SERVICE_DIR -Dknot.plugins.dir=$PLUGIN_DIR &
sleep 5

echo "deploying war"
chmod +x $WILDFLY_CLI
$WILDFLY_CLI --connect command="deploy $SCRIPT_DIR/../../knot-server/target/knot-server.war"
sleep 2

# any config?

echo "stopping wildfly"
$WILDFLY_CLI --connect command=:shutdown
sleep 3

